/*
 * usb_descriptors.c
 *
 *  Created on: 16.02.2021
 *      Author: Yannick
 */
#include "tusb.h"
#include "usb_descriptors.h"
#include "device/usbd.h"
#include "stm32f4xx_hal.h"
#include "main.h"
#include "usb_hid_ffb_desc.h"
#include "ffb_defs.h"

//--------------------------------------------------------------------+
// Device Descriptors
//--------------------------------------------------------------------+
#define USBD_VID     0x3416	//0x1209	//
#define USBD_PID     0x1001 //0x0008	//
const tusb_desc_device_t usb_devdesc_ffboard_composite =
{
    .bLength            = sizeof(tusb_desc_device_t),
    .bDescriptorType    = TUSB_DESC_DEVICE,
    .bcdUSB             = 0x0200,

    // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
    .bDeviceClass       = TUSB_CLASS_MISC,
    .bDeviceSubClass    = MISC_SUBCLASS_COMMON,
    .bDeviceProtocol    = MISC_PROTOCOL_IAD,
    .bMaxPacketSize0    = CFG_TUD_ENDPOINT0_SIZE,

    .idVendor           = USBD_VID,
    .idProduct          = USBD_PID,
    .bcdDevice          = 0x0100,

    .iManufacturer      = 0x01,
    .iProduct           = 0x02,
    .iSerialNumber      = 0x03,

    .bNumConfigurations = 0x01
};


/*--------------------------------------------------------------------
 * Configuration descriptors
 * String index starts at 4 (interfaces field)
----------------------------------------------------------------------*/

const uint8_t usb_cdc_conf[] =
{
  // Config number, interface count, string index, total length, attribute, power in mA
  TUD_CONFIG_DESCRIPTOR(1, 2, 0, (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN), TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),

  // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),
};

// Composite CDC and HID
#ifdef AXIS1_FFB_HID_DESC
const uint8_t usb_cdc_hid_conf_1axis[] =
{
  // Config number, interface count, string index, total length, attribute, power in mA
  TUD_CONFIG_DESCRIPTOR(1, 3, 0, (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_HID_INOUT_DESC_LEN), TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),

  // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),

  // HID Descriptor. EP 83 and 2
  TUD_HID_INOUT_DESCRIPTOR(2, 5, HID_ITF_PROTOCOL_NONE, USB_HID_1FFB_REPORT_DESC_SIZE, 0x83, 0x02, 64, HID_BINTERVAL),
};
#endif

// Composite CDC and HID
#ifdef AXIS2_FFB_HID_DESC
const uint8_t usb_cdc_hid_conf_2axis[] =
{
  // Config number, interface count, string index, total length, attribute, power in mA
  TUD_CONFIG_DESCRIPTOR(1, 3, 0, (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_HID_INOUT_DESC_LEN), TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),

  // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),

  // HID Descriptor. EP 83 and 2
  TUD_HID_INOUT_DESCRIPTOR(2, 5, HID_ITF_PROTOCOL_NONE, USB_HID_2FFB_REPORT_DESC_SIZE, 0x83, 0x02, 64, HID_BINTERVAL),
};
#endif

uint8_t const usb_cdc_hid_conf[] = 
{
	//Configuration Descriptor 1
	0x09,			//bLength
	0x02,           //bDescriptorType
	0x6B, 0x00,     //wTotalLength	usb_cdc_hid_conf�ĳ���
	0x03,           //bNumInterfaces
	0x01,           //bConfigurationValue
	0x02,           //iConfiguration
	0xC0,           //bmAttributes
	0x32,           //bMaxPower
	
	//Interface Association Descriptor Abstract Control Model
	0x08,			//bLength
	0x0B,           //bDescriptorType	Interface Association
	0x00,           //bFirstInterface
	0x02,           //bInterfaceCount
	0x02,           //bFunctionClass	CDC Control
	0x02,           //bFunctionSubClass		Abstract Control Model
	0x01,           //bFunctionProtocol		AT Commands: V.250 etc
	0x02,           //iFunction
	
	//Interface Descriptor 0/0 CDC Control, 1 Endpoint
	0x09,			//bLength
	0x04,           //bDescriptorType	Interface
	0x00,           //bInterfaceNumber
	0x00,           //bAlternateSetting
	0x01,           //bNumEndpoints
	0x02,           //bInterfaceClass	CDC Control
	0x02,           //bInterfaceSubClass	Abstract Control Model
	0x01,           //bInterfaceProtocol	AT Commands: V.250 etc
	0x00,           //iInterface
	
	//Header Functional Descriptor
	0x05,			//bFunctionLength
	0x24,           //bDescriptorType	CS Interface
	0x00,           //bDescriptorSubtype	Header
	0x10, 0x01,     //bcdCDC
	
	//Call Management Functional Descriptor
	0x05,			 //bFunctionLength
	0x24,            //bDescriptorType:	CS Interface
	0x01,            //bDescriptorSubtype	:Call Management
	0x00,            //bmCapabilities	
	0x01,            //bDataInterface
	
	//Abstract Control Management Functional Descriptor
	0x04,			//bFunctionLength
	0x24,           //bDescriptorType:CS Interface
	0x02,           //bDescriptorSubtype:Abstract Control Management
	0x02,           //bmCapabilities
	
	//Union Functional Descriptor
	0x05,			//bFunctionLength
	0x24,           //bDescriptorType:CS Interface
	0x06,           //bDescriptorSubtype:Union
	0x00,           //bControlInterface
	0x01,           //bSubordinateInterface0:CDC Data
	
	//Endpoint Descriptor 82 2 In, Interrupt, 16 ms
	0x07,			//bLength
	0x05,           //bDescriptorType:Endpoint
	0x83,           //bEndpointAddress:82h	2 In
	0x03,           //bmAttributes:03h	Interrupt
	0x08, 0x00,     //wMaxPacketSize:8 bytes
	0x10,           //bInterval	1	10h	16 ms
	
	//Interface Descriptor 1/0 CDC Data, 2 Endpoints
	0x09,			//bLength	1	09h	
	0x04,           //bDescriptorType	1	04h	Interface
	0x01,           //bInterfaceNumber	1	01h	
	0x00,           //bAlternateSetting	1	00h	
	0x02,           //bNumEndpoints	1	02h	
	0x0A,           //bInterfaceClass	1	0Ah	CDC Data
	0x00,           //bInterfaceSubClass	1	00h	
	0x00,           //bInterfaceProtocol	1	00h	
	0x00,           //iInterface	1	00h	
	
	//Endpoint Descriptor 01 1 Out, Bulk, 64 byte
	0x07,			//bLength	1	07h	
	0x05,           //bDescriptorType	1	05h	Endpoint
	0x01,           //bEndpointAddress	1	01h	1 Out
	0x02,           //bmAttributes	1	02h	Bulk
	0x40, 0x00,     //wMaxPacketSize	2	0040h	64 bytes
	0x00,           //bInterval	1	00h	
	
	//Endpoint Descriptor 81 1 In, Bulk, 64 bytes
	0x07,			//bLength	1	07h	
	0x05,           //bDescriptorType	1	05h	Endpoint
	0x81,           //bEndpointAddress	1	81h	1 In
	0x02,           //bmAttributes	1	02h	Bulk
	0x40, 0x00,     //wMaxPacketSize	2	0040h	64 bytes
	0x00,           //bInterval	1	00h	
	
	//Interface Descriptor 2/0 HID, 2 Endpoints
	0x09,			//bLength	1	09h	
	0x04,           //bDescriptorType	1	04h	Interface
	0x02,           //bInterfaceNumber	1	02h	
	0x00,           //bAlternateSetting	1	00h	
	0x02,           //bNumEndpoints	1	02h	
	0x03,           //bInterfaceClass	1	03h	HID
	0x00,           //bInterfaceSubClass	1	00h	
	0x00,           //bInterfaceProtocol	1	00h	
	0x02,           //iInterface	1	02h	"CAMMUS DDWB 2021"
	
	//HID Descriptor
	0x09,			//bLength	1	09h	
	0x21,           //bDescriptorType	1	21h	HID
	0x11, 0x01,     //bcdHID	2	0111h	1.11
	0x00,           //bCountryCode	1	00h	
	0x01,           //bNumDescriptors	1	01h	
	0x22,           //bDescriptorType	1	22h	Report
	0x62, 0x05,     //wDescriptorLength	2	0562h	1378 bytes	AT:�˴�����hid_descriptor_report�ĳ���
	
	//Endpoint Descriptor 83?3 In, Interrupt, 1 ms
	0x07,			//bLength	1	07h	
	0x05,           //bDescriptorType	1	05h	Endpoint
	0x82,           //bEndpointAddress	1	83h	3 In
	0x03,           //bmAttributes	1	03h	Interrupt
	0x40, 0x00,     //wMaxPacketSize	2	0040h	64 bytes
	0x05,           //bInterval	1	01h	1 ms --> 2 ms gzg
	
	//Endpoint Descriptor 02 2 Out, Interrupt, 1 ms
	0x07,			//bLength	1	07h	
	0x05,           //bDescriptorType	1	05h	Endpoint
	0x02,           //bEndpointAddress	1	02h	2 Out
	0x03,           //bmAttributes	1	03h	Interrupt
	0x40, 0x00,     //wMaxPacketSize	2	0040h	64 bytes
	0x05,           //bInterval	1	01h	1 ms --> 2 ms gzg

};

/*
	the difference between input,output and feature item
	Input item tag: Refers to the data from one or more similar controls on a
	device. For example, variable data such as reading the position of a single axis
	or a group of levers or array data such as one or more push buttons or
	switches.
	Output item tag: Refers to the data to one or more similar controls on a device
	such as setting the position of a single axis or a group of levers (variable data).
	Or, it can represent data to one or more LEDs (array data).
	Feature item tag: Describes device input and output not intended for
	consumption by the end user ��for example, a software feature or Control
	Panel toggle.
	Collection item tag: A meaningful grouping of Input, Output, and Feature
	items��for example, mouse, keyboard, joystick, and pointer.
	End Collection item tag: A terminating item used to specify the end of a
	collection of items.
 */

//cammus��������
const uint8_t hidff_descriptor_report[] = 
{
	//Interface 2 HID Report Descriptor Game Pad
	0x05,  0x01,                            //Usage Page (Generic Desktop) 
	0x09,  0x05,                            //Usage (Game Pad) 
	0xA1,  0x01,                            //Collection (Application) 
	0xA1,  0x00,                            //Collection (Physical) 
	0x85,  HID_ID_GAME_PAD,                 //Report ID (1) 
	0x05,  0x09,                            //Usage Page (Button) 
	0x19,  0x01,                            //Usage Minimum (Button 1) 
	0x29,  0x40,                            //Usage Maximum (Button 64) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x25,  0x01,                            //Logical Maximum (1) 
	0x95,  0x40,                            //Report Count (64) 
	0x75,  0x01,                            //Report Size (1) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0x05,  0x01,                            //Usage Page (Generic Desktop) 
	0x09,  HID_USAGE_X,                     //Usage (X) 
	0x09,  HID_USAGE_Y,                     //Usage (Y) 
	0x09,  HID_USAGE_Z,                     //Usage (Z) 
	0x09,  HID_USAGE_RX,                    //Usage (Rx) 
	0x09,  HID_USAGE_RY,                    //Usage (Ry) 
	0x09,  HID_USAGE_RZ,                    //Usage (Rz) 
	0x09,  HID_USAGE_DIAL,                	//Usage (Dial) 
	0x09,  HID_USAGE_SLIDER,                //Usage (Slider) 
	0x16,  0x00,  0x80,                     //Logical Minimum (-32768) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x08,                            //Report Count (8) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0xC0,                                   //End Collection 
	
	0x06,  0x00,  0xFF,                     //Usage Page (Vendor-Defined 1) 
	0x09,  0x00,                            //Usage (Undefined) 
	0xA1,  0x01,                            //Collection (Application) 
	0x85,  HID_ID_CUSTOMCMD,                //Report ID (175) 
	0x09,  0x01,                            //Usage (Vendor-Defined 1) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0x04,  0x00,                     //Logical Maximum (4) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x02,                            //Usage (Vendor-Defined 2) 
	0x09,  0x03,                            //Usage (Vendor-Defined 3) 
	0x75,  0x20,                            //Report Size (32) 
	0x95,  0x02,                            //Report Count (2) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x04,                            //Usage (Vendor-Defined 4) 
	0x75,  0x40,                            //Report Size (64) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 

	0x85,  HID_ID_CUSTOMCMD,                //Report ID (175) 
	0x09,  0x01,                            //Usage (Vendor-Defined 1) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0x04,  0x00,                     //Logical Maximum (4) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x02,                            //Usage (Vendor-Defined 2) 
	0x09,  0x03,                            //Usage (Vendor-Defined 3) 
	0x75,  0x20,                            //Report Size (32) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x04,                            //Usage (Vendor-Defined 4) 
	0x75,  0x40,                            //Report Size (64) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	
	0x85,  HID_ID_CUSTOMCMD,                //Report ID (175) 
	0x09,  0x01,                            //Usage (Vendor-Defined 1) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0x04,  0x00,                     //Logical Maximum (4) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0x09,  0x02,                            //Usage (Vendor-Defined 2) 
	0x09,  0x03,                            //Usage (Vendor-Defined 3) 
	0x75,  0x20,                            //Report Size (32) 
	0x95,  0x02,                            //Report Count (2) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0x09,  0x04,                            //Usage (Vendor-Defined 4) 
	0x75,  0x40,                            //Report Size (64) 
	0x95,  0x01,                            //Report Count (1) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0xC0,                                   //End Collection

	0x05,  0x0F,                            //Usage Page (Physical Input Device) 
	0x09,  0x92,                            //Usage (PID State Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_STATE+FFB_ID_OFFSET,      //Report ID (2) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0x09,  0x9F,                            //Usage (Device Paused) 
	0x09,  0xA0,                            //Usage (Actuators Enabled) 
	0x09,  0xA4,                            //Usage (Safety Switch) 
	0x09,  0xA6,                            //Usage (Actuator Power) 
	0x09,  0x94,                            //Usage (Effect Playing) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x25,  0x01,                            //Logical Maximum (1) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x45,  0x01,                            //Physical Maximum (1) 
	0x75,  0x01,                            //Report Size (1) 
	0x95,  0x05,                            //Report Count (5) 
	0x81,  0x02,                            //Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0x95,  0x03,                            //Report Count (3) 
	0x81,  0x03,                            //Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 
	0xC0,                                   //End Collection
	
	0x09,  0x21,                            //Usage (Set Effect Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_EFFREP+FFB_ID_OFFSET,     //Report ID (1) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  0x28,                            //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  0x28,                            //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x25,                            //Usage (Effect Type) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x09,  HID_USAGE_CONST,               	//Usage (ET Constant Force) 
	0x09,  HID_USAGE_RAMP,                  //Usage (ET Ramp) 
	0x09,  HID_USAGE_SQUR,                  //Usage (ET Square) 
	0x09,  HID_USAGE_SINE,                  //Usage (ET Sine) 
	0x09,  HID_USAGE_TRNG,                  //Usage (ET Triangle) 
	0x09,  HID_USAGE_STUP,                  //Usage (ET Sawtooth Up) 
	0x09,  HID_USAGE_STDN,                  //Usage (ET Sawtooth Down)
	0x09,  HID_USAGE_SPRNG,                 //Usage (ET Spring)
	0x09,  HID_USAGE_DMPR,                  //Usage (ET Damper) 
	0x09,  HID_USAGE_INRT,                  //Usage (ET Inertia) 
	0x09,  HID_USAGE_FRIC,                  //Usage (ET Friction) 
	0x09,  HID_USAGE_CUS,                   //Usage (ET Custom Force Data) 
	0x25,  0x0C,                            //Logical Maximum (12) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  0x0C,                            //Physical Maximum (12) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x00,                            //Output (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0x09,  0x50,                            //Usage (Duration) 
	0x09,  0x54,                            //Usage (Trigger Repeat Interval) 
	0x09,  0x51,                            //Usage (Sample Period) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x66,  0x03,  0x10,                     //Unit (Eng Lin: Time (s)) 
	0x55,  0xFD,                            //Unit Exponent 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x03,                            //Report Count (3) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x55,  0x00,                            //Unit Exponent (0) 
	0x66,  0x00,  0x00,                     //Unit (None) 
	0x09,  0x52,                            //Usage (Gain) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x53,                            //Usage (Trigger Button) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  0x08,                            //Logical Maximum (8) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  0x08,                            //Physical Maximum (8) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x55,                            //Usage (Axes Enable) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x05,  0x01,                            //Usage Page (Generic Desktop) 
	0x09,  0x30,                            //Usage (X) 
	0x09,  0x31,                            //Usage (Y) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x25,  0x01,                            //Logical Maximum (1) 
	0x75,  0x01,                            //Report Size (1) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	0x05,  0x0F,                            //Usage Page (Physical Input Device) 
	0x09,  0x56,                            //Usage (Direction Enable) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x95,  0x05,                            //Report Count (5) 
	0x91,  0x03,                            //Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x57,                            //Usage (Direction) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x0B,  0x01,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 1) 
	0x0B,  0x02,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 2) 
	0x66,  0x14,  0x00,                     //Unit (Eng Rot: Degree) 
	0x55,  0xFE,                            //Unit Exponent 
	0x15,  0x00,                            //Logical Minimum (0) 
//	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x27,  0xA0,  0x8C,  0x00,  0x00,		//Logical Maximum 8CA0h (36000d)
	0x35,  0x00,                            //Physical Minimum (0) 
	0x47,  0xA0,  0x8C,  0x00,  0x00,       //Physical Maximum (36000) 
	0x66,  0x00,  0x00,                     //Unit (None) 
//	0x75,  0x08,                            //Report Size (8) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x55,  0x00,                            //Unit Exponent (0) 
	0x66,  0x00,  0x00,                     //Unit (None) 
	0xC0,                                   //End Collection 
	0x05,  0x0F,                            //Usage Page (Physical Input Device) 
	0x09,  0x58,                            //Usage (Type Specific Block Offset) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x0B,  0x01,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 1) 
	0x0B,  0x02,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 2) 
	0x26,  0xFD,  0x7F,                     //Logical Maximum (32765) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0xC0,                                   //End Collection
	
	0x09,  0x5A,                            //Usage (Set Envelope Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_ENVREP+FFB_ID_OFFSET,     //Report ID (2) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x5B,                            //Usage (Attack Level) 
	0x09,  0x5D,                            //Usage (Fade Level) 
	0x16,  0x00,  0x00,                     //Logical Minimum (0) 
	0x26,  0x10,  0x27,                     //Logical Maximum (10000) 
	0x36,  0x00,  0x00,                     //Physical Minimum (0) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x5C,                            //Usage (Attack Time) 
	0x09,  0x5E,                            //Usage (Fade Time) 
	0x66,  0x03,  0x10,                     //Unit (Eng Lin: Time (s)) 
	0x55,  0xFD,                            //Unit Exponent 
	0x27,  0xFF,  0x7F,  0x00,  0x00,       //Logical Maximum (32767) 
	0x47,  0xFF,  0x7F,  0x00,  0x00,       //Physical Maximum (32767) 
	0x75,  0x20,                            //Report Size (32) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x45,  0x00,                            //Physical Maximum (0) 
	0x66,  0x00,  0x00,                     //Unit (None) 
	0x55,  0x00,                            //Unit Exponent (0) 
	0xC0,                                   //End Collection 
	
	0x09,  0x5F,                            //Usage (Set Condition Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_CONDREP+FFB_ID_OFFSET,    //Report ID (3) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x23,                            //Usage (Parameter Block Offset) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x25,  0x03,                            //Logical Maximum (3) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x45,  0x03,                            //Physical Maximum (3) 
	0x75,  0x04,                            //Report Size (4) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x58,                            //Usage (Type Specific Block Offset) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x0B,  0x01,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 1) 
	0x0B,  0x02,  0x00,  0x0A,  0x00,       //Usage (Ordinal:Ordinal 2) 
	0x75,  0x02,                            //Report Size (2) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	0x16,  0x00,  0x80,                     //Logical Minimum (-32768) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x36,  0x00,  0x80,                     //Physical Minimum (-32768) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x09,  0x60,                            //Usage (CP Offset) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x36,  0x00,  0x80,                     //Physical Minimum (-32768) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x09,  0x61,                            //Usage (Positive Coefficient) 
	0x09,  0x62,                            //Usage (Negative Coefficient) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x16,  0x00,  0x00,                     //Logical Minimum (0) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x36,  0x00,  0x00,                     //Physical Minimum (0) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x09,  0x63,                            //Usage (Positive Saturation) 
	0x09,  0x64,                            //Usage (Negative Saturation) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x65,                            //Usage (Dead Band) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	
	0x09,  0x6E,                            //Usage (Set Periodic Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_PRIDREP+FFB_ID_OFFSET,    //Report ID (4) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x70,                            //Usage (Magnitude) 
	0x16,  0x00,  0x00,                     //Logical Minimum (0) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x36,  0x00,  0x00,                     //Physical Minimum (0) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x6F,                            //Usage (Offset) 
	0x16,  0xF0,  0xD8,                     //Logical Minimum (-10000) 
	0x26,  0x10,  0x27,                     //Logical Maximum (10000) 
	0x36,  0xF0,  0xD8,                     //Physical Minimum (-10000) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x95,  0x01,                            //Report Count (1) 
	0x75,  0x10,                            //Report Size (16) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x71,                            //Usage (Phase) 
	0x66,  0x14,  0x00,                     //Unit (Eng Rot: Degree) 
	0x55,  0xFE,                            //Unit Exponent 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x27,  0x9F,  0x8C,  0x00,  0x00,       //Logical Maximum (35999) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x47,  0x9F,  0x8C,  0x00,  0x00,       //Physical Maximum (35999) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x72,                            //Usage (Period) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x27,  0xFF,  0x7F,  0x00,  0x00,       //Logical Maximum (32767) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x47,  0xFF,  0x7F,  0x00,  0x00,       //Physical Maximum (32767) 
	0x66,  0x03,  0x10,                     //Unit (Eng Lin: Time (s)) 
	0x55,  0xFD,                            //Unit Exponent(10 -3)ms
	0x75,  0x20,                            //Report Size (32) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x66,  0x00,  0x00,                     //Unit (None) 
	0x55,  0x00,                            //Unit Exponent (0) 
	0xC0,                                   //End Collection 
	
	0x09,  0x73,                            //Usage (Set Constant Force Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_CONSTREP+FFB_ID_OFFSET,   //Report ID (5) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x70,                            //Usage (Magnitude) 
	0x16,  0x00,  0x80,                     //Logical Minimum (-32768) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x36,  0x00,  0x80,                     //Physical Minimum (-32768) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	
	0x09,  0x74,                            //Usage (Set Ramp Force Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_RAMPREP+FFB_ID_OFFSET,    //Report ID (6) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x75,                            //Usage (Ramp Start) 
	0x09,  0x76,                            //Usage (Ramp End) 
	0x16,  0xF0,  0xD8,                     //Logical Minimum (-10000) 
	0x26,  0x10,  0x27,                     //Logical Maximum (10000) 
	0x36,  0xF0,  0xD8,                     //Physical Minimum (-10000) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	
	0x09,  0x68,                            //Usage (Custom Force Data Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  0x07,                            //Report ID (7) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x6C,                            //Usage (Custom Force Data Offset) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0x10,  0x27,                     //Logical Maximum (10000) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x69,                            //Usage (Custom Force Data) 
	0x15,  0x81,                            //Logical Minimum (-127) 
	0x25,  0x7F,                            //Logical Maximum (127) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x00,                     //Physical Maximum (255) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x0C,                            //Report Count (12) 
	0x92,  0x02,  0x01,                     //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Buf) 
	0xC0,                                   //End Collection
	
	0x09,  0x66,                            //Usage (Download Force Sample) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  0x08,                            //Report ID (8) 
	0x05,  0x01,                            //Usage Page (Generic Desktop) 
	0x09,  0x30,                            //Usage (X) 
	0x09,  0x31,                            //Usage (Y) 
	0x15,  0x81,                            //Logical Minimum (-127) 
	0x25,  0x7F,                            //Logical Maximum (127) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x00,                     //Physical Maximum (255) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x02,                            //Report Count (2) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	
	0x05,  0x0F,                            //Usage Page (Physical Input Device) 
	0x09,  0x77,                            //Usage (Effect Operation Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_EFOPREP+FFB_ID_OFFSET,    //Report ID (10) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x78,                            //Usage (Effect Operation) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x09,  0x79,                            //Usage (Op Effect Start) 
	0x09,  0x7A,                            //Usage (Op Effect Start Solo) 
	0x09,  0x7B,                            //Usage (Op Effect Stop) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  0x03,                            //Logical Maximum (3) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x00,                            //Output (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0x09,  0x7C,                            //Usage (Loop Count) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x00,                     //Physical Maximum (255) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	
	0x09,  0x90,                            //Usage (PID Block Free Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_BLKFRREP+FFB_ID_OFFSET,   //Report ID (11) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	
	/*DC short for Device Control*/
	0x09,  0x95,                            //Usage (PID Device Control Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_CTRLREP+FFB_ID_OFFSET,    //Report ID (12) 
	0x09,  0x96,                            //Usage (PID Device Control) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x09,  0x97,                            //Usage (DC Enable Actuators) 
	0x09,  0x98,                            //Usage (DC Disable Actuators) 
	0x09,  0x99,                            //Usage (DC Stop All Effects) 
	0x09,  0x9A,                            //Usage (DC Device Reset) 
	0x09,  0x9B,                            //Usage (DC Device Pause) 
	0x09,  0x9C,                            //Usage (DC Device Continue) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  0x06,                            //Logical Maximum (6) 
	0x75,  0x01,                            //Report Size (1) 
	0x95,  0x08,                            //Report Count (8) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0xC0,                                   //End Collection
	
	0x09,  0x7D,                            //Usage (Device Gain Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_GAINREP+FFB_ID_OFFSET,    //Report ID (13) 
	0x09,  0x7E,                            //Usage (Device Gain) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0x10,  0x27,                     //Physical Maximum (10000) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	
	0x09,  0x6B,                            //Usage (Set Custom Force Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  0x0E,                            //Report ID (14) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x6D,                            //Usage (Sample Count) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x00,                     //Physical Maximum (255) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x51,                            //Usage (Sample Period) 
	0x66,  0x03,  0x10,                     //Unit (Eng Lin: Time (s)) 
	0x55,  0xFD,                            //Unit Exponent 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x7F,                     //Logical Maximum (32767) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x7F,                     //Physical Maximum (32767) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x91,  0x02,                            //Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x55,  0x00,                            //Unit Exponent (0) 
	0x66,  0x00,  0x00,                     //Unit (None) 
	0xC0,                                   //End Collection
	
	0x09,  0xAB,                            //Usage (Create New Effect Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_NEWEFREP+FFB_ID_OFFSET,   //Report ID (17) 
	0x09,  0x25,                            //Usage (Effect Type) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x09,  HID_USAGE_CONST,                 //Usage (ET Constant Force) 
	0x09,  HID_USAGE_RAMP,                  //Usage (ET Ramp) 
	0x09,  HID_USAGE_SQUR,                  //Usage (ET Square) 
	0x09,  HID_USAGE_SINE,                  //Usage (ET Sine) 
	0x09,  HID_USAGE_TRNG,                  //Usage (ET Triangle) 
	0x09,  HID_USAGE_STUP,                  //Usage (ET Sawtooth Up) 
	0x09,  HID_USAGE_STDN,                  //Usage (ET Sawtooth Down) 
	0x09,  HID_USAGE_SPRNG,                 //Usage (ET Spring) 
	0x09,  HID_USAGE_DMPR,                  //Usage (ET Damper) 
	0x09,  HID_USAGE_INRT,                  //Usage (ET Inertia) 
	0x09,  HID_USAGE_FRIC,                  //Usage (ET Friction) 
	0x09,  HID_USAGE_CUS,                   //Usage (ET Custom Force Data) 
	0x25,  0x0C,                            //Logical Maximum (12) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  0x0C,                            //Physical Maximum (12) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x00,                            //Feature (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0x05,  0x01,                            //Usage Page (Generic Desktop) 
	0x09,  0x3B,                            //Usage (Byte Count) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x26,  0xFF,  0x01,                     //Logical Maximum (511) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x46,  0xFF,  0x01,                     //Physical Maximum (511) 
	0x75,  0x0A,                            //Report Size (10) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x75,  0x06,                            //Report Size (6) 
	0xB1,  0x01,                            //Feature (Cnst,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	
	0x05,  0x0F,                            //Usage Page (Physical Input Device) 
	0x09,  0x89,                            //Usage (PID Block Load Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_BLKLDREP+FFB_ID_OFFSET,   //Report ID (18) 
	0x09,  0x22,                            //Usage (Effect Block Index) 
	0x25,  MAX_EFFECTS,                     //Logical Maximum (40) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  MAX_EFFECTS,                     //Physical Maximum (40) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x8B,                            //Usage (Block Load Status) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x09,  0x8C,                            //Usage (Block Load Success) 
	0x09,  0x8D,                            //Usage (Block Load Full) 
	0x09,  0x8E,                            //Usage (Block Load Error) 
	0x25,  0x03,                            //Logical Maximum (3) 
	0x15,  0x01,                            //Logical Minimum (1) 
	0x35,  0x01,                            //Physical Minimum (1) 
	0x45,  0x03,                            //Physical Maximum (3) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x00,                            //Feature (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	0x09,  0xAC,                            //Usage (RAM Pool Available) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x27,  0xFF,  0xFF,  0x00,  0x00,       //Logical Maximum (65535) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x47,  0xFF,  0xFF,  0x00,  0x00,       //Physical Maximum (65535) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x00,                            //Feature (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection
	
	0x09,  0x7F,                            //Usage (PID Pool Report) 
	0xA1,  0x02,                            //Collection (Logical) 
	0x85,  HID_ID_POOLREP+FFB_ID_OFFSET,    //Report ID (19) 
	0x09,  0x80,                            //Usage (RAM Pool Size) 
	0x75,  0x10,                            //Report Size (16) 
	0x95,  0x01,                            //Report Count (1) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x27,  0xFF,  0xFF,  0x00,  0x00,       //Logical Maximum (65535) 
	0x47,  0xFF,  0xFF,  0x00,  0x00,       //Physical Maximum (65535) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0x83,                            //Usage (Simultaneous Effects Max) 
	0x26,  0xFF,  0x00,                     //Logical Maximum (255) 
	0x46,  0xFF,  0x00,                     //Physical Maximum (255) 
	0x75,  0x08,                            //Report Size (8) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x09,  0xA9,                            //Usage (Device Managed Pool) 
	0x09,  0xAA,                            //Usage (Shared Parameter Blocks) 
	0x75,  0x01,                            //Report Size (1) 
	0x95,  0x02,                            //Report Count (2) 
	0x15,  0x00,                            //Logical Minimum (0) 
	0x25,  0x01,                            //Logical Maximum (1) 
	0x35,  0x00,                            //Physical Minimum (0) 
	0x45,  0x01,                            //Physical Maximum (1) 
	0xB1,  0x02,                            //Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0x75,  0x06,                            //Report Size (6) 
	0x95,  0x01,                            //Report Count (1) 
	0xB1,  0x03,                            //Feature (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 
	0xC0,                                   //End Collection 
	0xC0,                                   //End Collection 
};





// Composite CDC and MIDI
uint8_t const usb_cdc_midi_conf[] =
{
  // Config number, interface count, string index, total length, attribute, power in mA
  TUD_CONFIG_DESCRIPTOR(1, 4, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MIDI_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
  // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
  TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),
  // Interface number, string index, EP Out & EP In address, EP size
//  TUD_MIDI_DESCRIPTOR(2, 6, 0x02, 0x83, 64)
};

//--------------------------------------------------------------------+
// String Descriptors
//--------------------------------------------------------------------+
uint16_t hidlen,configlen;
// Default ffboard names
const usb_string_desc_t usb_ffboard_strings_default = {
	.langId = 0x0409,
	.manufacturer = "Guangzhou Zhuoyuan Virtual Reality Tech Co.,Ltd",//"CAMMUS",
	.product = "FFB WHEEL",//"CAMMUS DDWB 2021",
	// Interfaces start at index 4
	.interfaces = {"CDC", "HID"}
};

void getHidLen(void)
{
	hidlen = sizeof(hidff_descriptor_report);
	configlen = sizeof(usb_cdc_hid_conf);
}




